package com.coy.web.controller;

import com.alibaba.fastjson.JSON;
import com.coy.web.common.consts.WebConsts;
import com.coy.web.common.dto.DataResult;
import com.coy.web.common.exception.BizResultCode;
import com.coy.web.feign.dto.RegAndLoginReq;
import com.coy.web.feign.dto.SmsReq;
import com.coy.web.feign.dto.UpdatePwdReq;
import com.coy.web.service.ILoginService;
import com.coy.web.util.SessionUtil;
import com.coy.web.zax.feign.dto.UserInfoDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import javax.validation.Valid;

/**
 * 登陆注册
 *
 * @author chenck
 * @date 2019/11/19 21:53
 */
@Slf4j
@RestController
@RequestMapping("/")
public class LoginController {

    @Resource
    ILoginService loginService;

    /**
     * 注册并登录
     */
    @PostMapping(value = "regAndLogin")
    public DataResult<UserInfoDTO> regAndLogin(@RequestBody @Valid RegAndLoginReq req) {
        // 先判断是否登录登录
        // 先注册
        return null;
    }

    /**
     * 登录
     */
    @PostMapping(value = "login")
    public DataResult<UserInfoDTO> login(@RequestBody @Valid RegAndLoginReq req) {
        return loginService.login(req);
    }

    /**
     * 修改密码
     */
    @PostMapping(value = "updatePwd")
    public DataResult updatePwd(@RequestBody @Valid UpdatePwdReq req) {
        return loginService.updatePwd(req);
    }
}
